﻿using System;

namespace HB.HttpServer
{
    /// <summary>
    /// 【覆盖特性】控制器自定义路由
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
    public class HttpRouter : Attribute
    {
        public string routerFormat { get; set; }
        /// <summary>
        /// 默认识别符 [controller],[action]  示例："/api/[controller]/[action]"
        /// </summary>
        /// <param name="format"></param>
        public HttpRouter(string format)
        {
            if (string.IsNullOrEmpty(format))
            {
                throw new Exception("Format Error");
            }
            if (!format.StartsWith("/"))
            {
                throw new Exception("Format Must Start With /");
            }
            routerFormat = format;
        }
    }
}
